package app.netant.book.lawen8;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;
/**
 * 
 * @author JiaJ
 *
 */
public class Lawen8Detail extends BaseDetail {

	public Lawen8Detail(String netSite) {
		super(netSite);
		this.preHref = "http://www.lawen8.me";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select(".main .mread .divbox div h2.ratitle");
		if(parts.size()>0){
			String title = parts.get(0).text();
			System.out.println("【Title】:"+title);
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".txt");
		}
	}

	@Override
	public void analyseTags() {
		Elements parts = this.select(".main .mread .divbox div div[style='line-height:2.5;']");
		if(parts.size()>0){
			String tags = parts.get(0).text().trim();
			//System.out.println(tags);
			tags = tags.replaceAll(" / ", " ");
			tags = tags.replaceAll("　　", " ");
			tags = tags.replaceAll("状态： ","");
			if(tags.endsWith("举报错误")){
				tags = tags.substring(0,tags.length()-4);
			}
			//System.out.println(tags);
			this.splitTags(tags, true);
		}
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select(".main .mread .divbox div div.gray");
		if(parts.size()>0){
			String memo = parts.get(0).text();
			System.out.println("【Memo】:"+memo);
			this.entity.setNovelMemo(memo);
		}
	}

	@Override
	public void analyseHref() {
		Elements parts = this.select(".main .mread .divbox div a.btnlink");
		for(int i=0;i<parts.size();i++){
			String text = parts.get(i).text();
			if("TXT全集下载".equals(text)){
				String href = parts.get(i).attr("href");
				if(href.startsWith("/")){
					href = this.preHref + href;
				}
				System.out.println("【Href】:"+href);
				this.entity.setDownPath(href);
				break;
			}
		}
	}
	
	@Override
	public void analyseType() {
		
	}
	
	public static void main(String[] args) {
		Lawen8Detail detail = new Lawen8Detail("http://www.lawen8.me/modules/article/reader.php?aid=3438");
		detail.test();
	}



}
